package com.qidian.controller;

import com.qidian.common.Result;
import com.qidian.pojo.Student;
import com.qidian.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 学生接口控制层
 * @author: liudz
 * @create: 2022-06-20 15:21
 **/
@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    /**
     * 注册
     * @return
     */
    @PostMapping("/registered")
    public Result registered(@RequestBody Student student){
        return studentService.registered(student);
    }


    /**
     * 登录
     * @param student
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody Student student){
        return studentService.login(student);
    }

    /**
     * 注销
     * @param id
     * @return
     */
    @GetMapping("/cancellation")
    public Result cancellation(@RequestParam("id") Integer id){
        return studentService.cancellation(id);
    }


    /**
     * 依据id修改学生信息
     * @param student
     * @return
     */
    @PostMapping("/update")
    public Result updateById(@RequestBody Student student){
        return studentService.updateById(student);
    }

}
